package com.zhitong.money.mapper;

import com.zhitong.money.entity.TokenEntity;
import org.apache.ibatis.annotations.*;

/**
 * @Author: Andy Zhang
 * @Description:
 * @Date: 11:14 2021/3/12
 * @Company: wisecard
 */
@Mapper
public interface ITokenEntityMapper {

    @Results(id = "tokenMap",value={
            @Result(column = "tid",property = "tid"),
            @Result(column = "token",property = "token"),
            @Result(column = "expireTime",property = "expireTime"),
            @Result(column = "updateTime",property = "updateTime"),
    })
    @Select("select * from token where token = #{token}")
    public TokenEntity findByToken(String token);

    @ResultMap("tokenMap")
    @Select("select * from token where tid = #{tid}")
    public TokenEntity findByTid(String tid);

    @Insert("insert into token values(#{tid},#{token},#{expireTime},#{updateTime})")
    public void add(TokenEntity tokenEntity);

    @Update("update token set token=#{token},expireTime=#{expireTime},updateTime=#{updateTime} where tid = #{tid}")
    public void update(TokenEntity tokenEntity);

    @Delete("delete from token where tid = #{tid}")
    public void del(String uid);

}
